﻿using DotNetUniLodz.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DotNetUniLodz.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/Index

        DotNetULEntities db = new DotNetULEntities();

        public ActionResult Index()
        {
            var model = db.Articles.Where(a => a.Article_isMainArticle).OrderByDescending(a => a.Article_id).ToList();
            return View(model);
        }

        [ChildActionOnly]
        public PartialViewResult _Events()
        {
            var events = db.Events.OrderByDescending(e => e.Event_date).Take(6).ToList();
            return PartialView(events);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
